package com.pds.web.area.controller;

import com.pds.common.core.controller.BaseController;
import com.pds.common.core.domain.R;
import com.pds.web.area.entity.Area;
import com.pds.web.area.service.AreaService;
import com.pds.web.area.vo.AreaProvinceVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;

/**
 * 位置地区表
 *
 * @author srf sunlightcs@gmail.com
 * @since 1.0.0 2024-03-15
 */
@RestController
@RequestMapping("/area")
@Api(tags="位置地区表")
public class AreaController extends BaseController {
    @Resource
    private AreaService areaService;

    /**
     * 查询行政地区列表
     *
     *   筛选条件字段
     * @return 查询结果
     */
    @ApiOperation("查询行政地区列表")
    @GetMapping("/list")
    public R<List<AreaProvinceVO>> listArea(Area area){
        List<AreaProvinceVO> list = areaService.queryArea();
        //List<AreaProvinceVO> list = areaService.selectList(area);
        return R.ok(list);
    }

    /**
     * 根据等级查询行政地区列表
     * @param level 等级 1省、2市、3区县、4街道
     * @return
     */
    @GetMapping("/listByLevel")
    public R listByLevel(@RequestParam Integer level){
        List<AreaProvinceVO> list = areaService.listByLevel(level);
        return R.ok(list);
    }
}
